#include "LogMgr.h"

LogMgr g_kLogMgr;

LogMgr::LogMgr()
{
}

LogMgr::~LogMgr()
{
}

bool LogMgr::Initialize(const char* acFileDir)
{
	m_kFileDir = acFileDir;
	return true;
}

void LogMgr::Write(char* acFmt,...)
{
	char acText[512] = {0};
	va_list	ArgList;
	va_start(ArgList,acFmt);
	vsprintf(acText,acFmt,ArgList);
	va_end(ArgList);

	SYSTEMTIME kTime;
	GetSystemTime(&kTime);
	char acFileName[128] = {0};
	sprintf_s(acFileName,sizeof(acFileName),"%s%02d_%02d_%02d.log",m_kFileDir.c_str(),kTime.wYear,kTime.wMonth,kTime.wDay);
	FILE* file = fopen(acFileName,"a+");
	if(!file)
	{
		return;
	}

	char acFileInput[1024] = {0};
	sprintf_s(acFileInput,sizeof(acFileInput),"%s\n Time:%02d_%02d_%02d\n\n",acText,kTime.wHour,kTime.wMinute,kTime.wSecond);
	fwrite(acFileInput,sizeof(acFileInput),1,file);
	fclose(file);
}